home *** CD-ROM | disk | FTP | other *** search
- {$P512}
- PROGRAM Dumper(input,output,picfile);
-
- { Copyright (c) 1987, Ciarcia's Circuit Cellar }
- { All Rights Reserved }
-
- {$U- control-break checking during execution }
- {$C+ control-break checking during I/O operations }
- {$R+ array range checking }
-
- {$Ideclares.p declarations }
- {$Ihexutil.p hex utilities }
- {$Iserial.p serial interface code }
- {$Ipictures.p picture file code }
- {$Iimages.p image processing }
-
- CONST
-
- FF = $0C; { ordinary form feed... }
-
-
- {-------------------------------------------------------}
- { Dump hex values in picture }
-
- PROCEDURE HexDump(pic : picptr);
-
- VAR
- picbyte : BYTE;
- bptr : ^BYTE;
- linectr : INTEGER;
-
- BEGIN
-
- bptr := Ptr(Seg(pic^),Ofs(pic^));
-
- Writeln;
- FOR linectr := 1 TO 16 DO
- Write('0123456789ABCDEF');
-
- Writeln;
- Writeln;
-
- linectr := -1;
-
- REPEAT
-
- picbyte := bptr^; { pick up the byte }
-
- CASE picbyte OF
- fieldsync : BEGIN
- Writeln('Field sync');
- linectr := -1;
- END;
- linesync : BEGIN
- linectr := linectr + 1;
- Writeln;
- Write(linectr:4,': ');
- END;
- fldend : BEGIN
- Writeln;
- Writeln('End of picture');
- END;
- fullres : BEGIN
- Writeln;
- Writeln('Full resolution');
- END;
- halfres : BEGIN
- Writeln;
- Writeln('Half resolution');
- END;
- quartres : BEGIN
- Writeln;
- Writeln('Quarter resolution');
- END;
- ELSE CASE (picbyte AND $F0) OF
- rep1 : BEGIN
- Write('x',(picbyte AND $0F),' ');
- END;
- rep16 : BEGIN
- Write('x',16*(picbyte AND $0F),' ');
- END;
- ELSE BEGIN
- Write(ByteToHex(picbyte),' ');
- END;
- END;
- END;
-
- bptr := Ptr(Seg(bptr^),Ofs(bptr^)+1);
-
- UNTIL picbyte = fldend;
-
- END;
-
-
- {-------------------------------------------------------}
- { Return a more or less unique character for each pel }
- { Note that the characters are defined globally }
-
- CONST
- csetlen = 64;
-
- charset : STRING[csetlen] =
- '.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*';
-
- FUNCTION Chars(ID : BYTE) : CHAR;
-
- BEGIN
-
- IF (ID < csetlen) AND (ID >= 0)
- THEN Chars := charset[ID+1]
- ELSE Chars := '?';
-
- END;
-
- {-------------------------------------------------------}
- { Dump formatted picture }
-
- PROCEDURE FmtDump(pic : picptr);
-
- VAR
- picbyte : BYTE;
- oldbyte : BYTE;
- bptr : ^BYTE;
- repcount : INTEGER;
- reps : INTEGER;
- done : BOOLEAN;
- linectr : INTEGER;
-
- BEGIN
-
- bptr := Ptr(Seg(pic^),Ofs(pic^));
- oldbyte := 0;
- done := FALSE;
-
- REPEAT
-
- picbyte := bptr^; { pick up the byte }
-
- CASE picbyte OF
- fieldsync : BEGIN
- Writeln;
- Writeln('Field sync');
- linectr := -1;
- END;
- linesync : BEGIN
- linectr := linectr + 1;
- Writeln; { eject to next line }
- Write(linectr:4,': ');
- oldbyte := 0; { reset memory }
- END;
- fldend : BEGIN
- Writeln;
- Writeln('End of picture');
- done := TRUE;
- END;
- fullres : BEGIN
- Writeln;
- Writeln('Full resolution');
- END;
- halfres : BEGIN
- Writeln;
- Writeln('Half resolution');
- END;
- quartres : BEGIN
- Writeln;
- Writeln('Quarter resolution');
- END;
- ELSE CASE (picbyte AND $F0) OF
- rep1 : BEGIN
- repcount := picbyte AND $0F;
- IF repcount = 0
- THEN repcount := 16;
- FOR reps := 1 TO repcount DO
- Write(Chars(oldbyte));
- END;
- rep16 : BEGIN
- repcount := 16 * (picbyte AND $0F);
- IF repcount = 0
- THEN repcount := 256;
- FOR reps := 1 TO repcount DO
- Write(Chars(oldbyte));
- END;
- ELSE BEGIN
- Write(Chars(picbyte));
- oldbyte := picbyte;
- END;
- END;
- END;
-
- bptr := Ptr(Seg(bptr^),Ofs(bptr^)+1);
-
- UNTIL done;
-
- END;
-
-
- {-------------------------------------------------------}
- { Main routine }
-
- BEGIN
-
- pic0 := NIL; { ensure new alloc }
- PicSetup(pic0); { set up picture array }
- LoadPicture(ParamStr(1),pic0); { load picture }
- FmtDump(pic0); { do formatted dump }
- Write(Chr(ff)); { eject the page }
- HexDump(pic0); { do hex dump }
-
- END.